{% extends "base.html" %}

{% block title %}编辑个人资料 - 车辆管理系统{% endblock %}

{% block content %}
<div class="container py-4">
    <div class="row mb-4">
        <div class="col">
            <h2>编辑个人资料</h2>
            <p class="text-muted">更新您的个人信息</p>
        </div>
        <div class="col-auto d-flex align-items-center">
            <a href="{{ url_for('user_profile') }}" class="btn btn-secondary">
                <i class="fas fa-arrow-left"></i> 返回个人资料
            </a>
        </div>
    </div>
    
    <div class="row">
        <div class="col-md-8 offset-md-2">
            <div class="card">
                <div class="card-header bg-primary text-white">
                    <h4 class="mb-0">编辑个人信息</h4>
                </div>
                <div class="card-body">
                    <form action="{{ url_for('edit_profile') }}" method="post">
                        <div class="mb-3">
                            <label for="username" class="form-label">用户名</label>
                            <input type="text" class="form-control" id="username" name="username" value="{{ user.username }}" required>
                        </div>
                        
                        <div class="mb-3">
                            <label for="phone" class="form-label">手机号</label>
                            <input type="tel" class="form-control" id="phone" name="phone" value="{{ user.phone }}" required pattern="[0-9]{11}">
                            <div class="form-text">请输入11位有效手机号码</div>
                        </div>
                        
                        <div class="mb-3">
                            <label class="form-label">用户角色</label>
                            <input type="text" class="form-control" value="{% if user.role == 'admin' %}管理员{% else %}普通用户{% endif %}" readonly>
                            <div class="form-text">用户角色不可修改</div>
                        </div>
                        
                        <div class="mb-3">
                            <label class="form-label">注册时间</label>
                            <input type="text" class="form-control" value="{{ user.created_at.strftime('%Y-%m-%d %H:%M:%S') }}" readonly>
                        </div>
                        
                        <div class="alert alert-warning">
                            <i class="fas fa-exclamation-triangle"></i> 注意：如果修改手机号，将影响您的登录凭证。
                        </div>
                        
                        <div class="d-grid gap-2">
                            <button type="submit" class="btn btn-primary">保存修改</button>
                            <a href="{{ url_for('user_profile') }}" class="btn btn-secondary">取消</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %} 